<extend name="work/base" />
<block name="content">

        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-normal layui-btn-sm ajax-form" data-url="{:url('add')}" title="添加规则"><i class="layui-icon">&#xe61f;</i> 添加规则</button>
                    <button class="layui-btn layui-btn-normal layui-btn-sm ajax-get"  get_list="0" data-url="{:url('/system/dbadmin/cache_clear')}">清理所有缓存</button>
                    <button class="layui-btn layui-btn-normal layui-btn-sm ajax-get"  get_list="0" data-url="{:url('/system/dbadmin/rule_clear')}">清理权限缓存</button>
                </div>
            </div>
            <div class="pull-right">
            </div>
        </form>
        <table class="layui-table text-center" id="list" lay-filter="list" list-url="{:url('lists')}" edit-url="{:url('edit')}" del-url="{:url('delete')}"></table>
    </div>
</block>
<block name="script">
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
    </script>
    <script type="text/html" id="status">
        <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="is_status" {{ d.status ==1?'checked' : '' }}>
    </script>
    <script type="text/html" id="is_menu">
        <input type="checkbox" name="is_menu" value="{{d.id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="is_member" {{ d.is_menu ==1?'checked' : '' }}>
    </script>
    <script type="text/javascript">
        layui.use([ 'element', 'table'], function(){
            var table = layui.table;
            table.render({
                elem: '#list'
                ,url:"{:Url('lists')}"
                ,toolbar: '<div></div>'
                ,page:false
                ,loading:true
                ,limit:20
                ,title:'权限表'
                ,defaultToolbar: ['filter', 'print', 'exports']
                ,cols: [[
                    {field:'title', width:250,  title: '名称', templet: '<div>{{d.html}}{{d.title}}</div>', edit: 'text'}
                    ,{field:'name', width:250,  title: '路由/规则' ,edit: 'text'}
                    ,{field:'icon', width:160, title: '图标',edit: 'text'}
                    ,{field:'sort', width:100, title: '权重', }
                    ,{field:'is_menu', width:100, title: '是否菜单', templet:'#is_menu'}
                    ,{field:'status', width:100, title: '正常/否', templet:'#status'}
                    ,{field:'remark', width:250, title: '备注', edit: 'text'}
                    ,{fixed: 'right', width:115,title:'操作',  toolbar:'#barDemo'}
                ]]
            });
        });
    </script>
</block>
</block>